<template>
  <a-card :bordered="false">
      <a-tabs v-model="bizTaskType" @change="handleChangeTabs">
      <a-tab-pane key="0" tab="所有通知单">
      </a-tab-pane>
      <a-tab-pane key="1">
        <span slot="tab">
          <a-badge :count="doTotal">
            待我处理&nbsp;&nbsp;&nbsp;
          </a-badge>
        </span>
      </a-tab-pane>
      <a-tab-pane key="2" tab="我发起的">
        <!--<span slot="tab">
          <a-badge :count="myTotal">
            我发起的&nbsp;&nbsp;&nbsp;
          </a-badge>
        </span>-->
      </a-tab-pane>
    </a-tabs>
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus" :disabled="isDisabledAuth('erpHrPostSalaryAdjustment:add')">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('员工调岗调薪申请表')" :disabled="isDisabledAuth('erpHrPostSalaryAdjustment:export')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import" :disabled="isDisabledAuth('erpHrPostSalaryAdjustment:import')">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <!--<j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel" :disabled="isDisabledAuth('erpHrPostSalaryAdjustment:delete')"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
      <a-popover title="自定义列" trigger="click" placement="leftBottom">
        <template slot="content">
          <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
            <a-row>
              <template v-for="(item,index) in defColumns">
                <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">
                  <a-col :span="12"><a-checkbox :value="item.dataIndex">{{ item.title }}</a-checkbox></a-col>
                </template>
              </template>
            </a-row>
          </a-checkbox-group>
        </template>
        <a style="float: right;"><a-icon type="setting" :style='iconStyle'/></a>
      </a-popover>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        :customRow="customRow"
        @change="handleTableChange">
        <span slot="notify" slot-scope="text, record">
          <a-icon title="催办提醒" v-if="record.taskUrge" theme="twoTone" twoToneColor="#eb2f96"
                  @click="taskNotifyMe(flowCode,record.id)" type="notification"/>
          {{ text }}
        </span>
        <template slot="status" slot-scope="status">
           <a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
        </template>
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
            <template v-if="record.bpmStatus === '1'">
            <a-button
                    class="ruleButton"
                    :ghost="true"
                    type="primary"
                    icon="edit"
                    @click="handleEdit(record)"
                    :disabled="isDisabledAuth('erpHrPostSalaryAdjustment:edit')"
            />
            <a-divider type="vertical"/>
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                <a-button
                        class="ruleButton"
                        :ghost="true"
                        type="primary"
                        icon="delete"
                        :disabled="isDisabledAuth('erpHrPostSalaryAdjustment:delete')"/>
            </a-popconfirm>
            <a-divider type="vertical"/>
            <a-button type="primary" size="small" @click="startProcess(record)" :disabled="isDisabledAuth('erpHrPostSalaryAdjustment:startProcess')">发起流程</a-button>
        </template>
        <template v-else-if="showBtn(record.bpmStatus)&&queryParam.bizTaskType=='1'">
            <a-button type="primary" size="small" @click="handleProcess(record)">办理</a-button>
            <a-divider type="vertical"/>
        </template>
        <template v-else-if="queryParam.bizTaskType=='2' && showBtn(record.bpmStatus)">
            <a-button type="primary" size="small" @click="taskNotify(flowCode,record.id)">催办</a-button>
            <a-divider type="vertical"/>
            <a-popconfirm title="确定要作废吗?" @confirm="() => invalidProcess(record)">
                <a-button type="primary" size="small" :disabled="isDisabledAuth('erpHrPostSalaryAdjustment:invalidProcess')">
                    作废流程
                </a-button>
            </a-popconfirm>
            <a-divider type="vertical"/>
        </template>
        <template v-if="record.bpmStatus !== '1'">
            <a-button type="primary" size="small" @click="handleTrack(record)" :disabled="isDisabledAuth('erpHrPostSalaryAdjustment:viewTrack')">审批进度</a-button>
        </template>
        </span>

      </a-table>
    </div>

    <erp-hr-post-salary-adjustment-modal ref="modalForm" @ok="modalFormOk"></erp-hr-post-salary-adjustment-modal>
    <bpm-biz-task-deal-modal ref="taskDealModal" :path="path" :formData="formData" @ok="handleOk"></bpm-biz-task-deal-modal>
    <bpm-process-track-modal ref="bpmProcessTrackModal"></bpm-process-track-modal>
    <biz-task-notify-modal ref="taskNotifyModal"></biz-task-notify-modal>
    <biz-task-notify-me-modal ref="taskNotifyMeModal"></biz-task-notify-me-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import {JeecgBpmListMixin} from '@/mixins/JeecgBpmListMixin'
  import BpmBizTaskDealModal from "@/views/modules/bpmbiz/common/BpmBizTaskDealModal.vue";
  import BpmProcessTrackModal from "@/views/modules/bpmbiz/common/BpmProcessTrackModal.vue";
  import BizTaskNotifyModal from "@/views/modules/bpmbiz/common/BizTaskNotifyModal.vue";
  import BizTaskNotifyMeModal from "@/views/modules/bpmbiz/common/BizTaskNotifyMeModal.vue";
  import ErpHrPostSalaryAdjustmentModal from './modules/ErpHrPostSalaryAdjustmentModal'
  import { postAction } from '@/api/manage'
  import {DisabledAuthFilterMixin} from '@/mixins/DisabledAuthFilterMixin'

  export default {
    name: 'ErpHrPostSalaryAdjustmentList',
    mixins:[JeecgBpmListMixin, mixinDevice, DisabledAuthFilterMixin],
    components: {
      ErpHrPostSalaryAdjustmentModal,
      BpmBizTaskDealModal,
      BpmProcessTrackModal,
      BizTaskNotifyModal,
      BizTaskNotifyMeModal,
    },
    data () {
      return {
        description: '员工调岗调薪申请表管理页面',
        //表头
        columns:[],
        //列设置
        settingColumns:[],
        // 列定义
        defColumns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'申请人',
            align:"center",
            dataIndex: 'employeeId_dictText',
          },
          {
            title:'人员编号',
            align:"center",
            dataIndex: 'employeeNo',
          },
          {
            title:'所在单位',
            align:"center",
            dataIndex: 'workUnit_dictText',
          },
          {
            title:'所在部门',
            align:"center",
            dataIndex: 'departmentId_dictText',
          },
          {
            title:'所属团队',
            align:"center",
            dataIndex: 'teamId_dictText',
          },
          {
            title:'岗位名称',
            align:"center",
            dataIndex: 'positionId_dictText',
          },
          {
            title:'调整前薪级',
            align:"center",
            dataIndex: 'beforeSalaryScale_dictText',
          },
          {
            title:'调整前薪资',
            align:"center",
            dataIndex: 'beforeSalary',
          },
          {
            title:'生效日期',
            align:"center",
            dataIndex: 'effectiveDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'调整后薪级',
            align:"center",
            dataIndex: 'afterSalaryScale_dictText',
          },
          {
            title:'调整后薪资',
            align:"center",
            dataIndex: 'afterSalary',
          },
          {
            title:'调整原因',
            align:"center",
            dataIndex: 'adjustRemark',
          },
          {
            title:'调入单位',
            align:"center",
            dataIndex: 'adjustUnit_dictText',
          },
          {
            title:'调入部门',
            align:"center",
            dataIndex: 'adjustDepart_dictText',
          },
          {
            title:'调入团队',
            align:"center",
            dataIndex: 'adjustTeam_dictText',
          },
          {
            title:'调入岗位',
            align:"center",
            dataIndex: 'adjustPosition_dictText',
          },
          {
            title:'公积金单位',
            align:"center",
            dataIndex: 'providentFundUnit_dictText',
          },
          {
            title:'参保单位',
            align:"center",
            dataIndex: 'insuredUnit_dictText',
          },
          {
            title:'参保基数（元）',
            align:"center",
            dataIndex: 'insuredBase',
          },
          {
            title:'公积金基数（元）',
            align:"center",
            dataIndex: 'providentFundBase',
          },
          {
            title:'备注',
            align:"center",
            dataIndex: 'remark',
          },
          {
            title:'附件',
            align:"center",
            dataIndex: 'attachment',
            scopedSlots: {customRender: 'fileSlot'}
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action' }
          }
        ],
        url: {
          list: "/api/erp/hr/adjust/erpHrPostSalaryAdjustment/list",
          delete: "/api/erp/hr/adjust/erpHrPostSalaryAdjustment/delete",
          deleteBatch: "/api/erp/hr/adjust/erpHrPostSalaryAdjustment/deleteBatch",
          exportXlsUrl: "/api/erp/hr/adjust/erpHrPostSalaryAdjustment/exportXls",
          importExcelUrl: "api/erp/hr/adjust/erpHrPostSalaryAdjustment/importExcel",
          bizCount: "/api/erp/hr/adjust/erpHrPostSalaryAdjustment/bizCount",
        },
        //代码生成后需手动设置流程编码
        flowCode: 'onl_erp_hr_post_salary_adjustment',
        formUrl: "erp/hr/adjust/modules/ErpHrPostSalaryAdjustmentForm",
        formUrlMobile: "",
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'sel_user',value:'employeeId',text:'申请人'})
        fieldList.push({type:'string',value:'employeeNo',text:'人员编号',dictCode:''})
        fieldList.push({type:'sel_depart',value:'workUnit',text:'所在单位'})
        fieldList.push({type:'sel_depart',value:'departmentId',text:'所在部门'})
        fieldList.push({type:'string',value:'teamId',text:'所属团队',dictCode:''})
        fieldList.push({type:'string',value:'positionId',text:'岗位名称',dictCode:''})
        fieldList.push({type:'string',value:'beforeSalaryScale',text:'调整前薪级',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'beforeSalary',text:'调整前薪资',dictCode:''})
        fieldList.push({type:'date',value:'effectiveDate',text:'生效日期'})
        fieldList.push({type:'string',value:'afterSalaryScale',text:'调整后薪级',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'afterSalary',text:'调整后薪资',dictCode:''})
        fieldList.push({type:'string',value:'adjustRemark',text:'调整原因',dictCode:''})
        fieldList.push({type:'string',value:'adjustUnit',text:'调入单位',dictCode:''})
        fieldList.push({type:'string',value:'adjustDepart',text:'调入部门',dictCode:''})
        fieldList.push({type:'string',value:'adjustTeam',text:'调入团队',dictCode:''})
        fieldList.push({type:'string',value:'adjustPosition',text:'调入岗位',dictCode:''})
        fieldList.push({type:'sel_depart',value:'providentFundUnit',text:'公积金单位'})
        fieldList.push({type:'sel_depart',value:'insuredUnit',text:'参保单位'})
        fieldList.push({type:'string',value:'insuredBase',text:'参保基数（元）',dictCode:''})
        fieldList.push({type:'string',value:'providentFundBase',text:'公积金基数（元）',dictCode:''})
        fieldList.push({type:'string',value:'remark',text:'备注',dictCode:''})
        fieldList.push({type:'Text',value:'attachment',text:'附件',dictCode:''})
        fieldList.push({type:'int',value:'checkStatua',text:'审核状态',dictCode:''})
        fieldList.push({type:'string',value:'bpmStatus',text:'流程状态',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
